<template>
  <div class="box-card">
    <el-container>
      <el-header height="57px" class="pass-header"> </el-header>
      <el-main class="pass-main">
        <div
          class="all-pass"
          v-loading="loading"
          element-loading-text="正在加载数据..."
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
        >
          <div class="left-box" v-if="!loading">
            <div class="playground-container">
              <div class="playground-top">
                <div class="little-block"></div>
                <div class="rate-block">{{ playgroundTopRate[0] + "%" }}</div>
                <div class="little-block"></div>
                <div class="rate-block">{{ playgroundTopRate[1] + "%" }}</div>
                <div class="little-block"></div>
                <div class="rate-block">{{ playgroundTopRate[2] + "%" }}</div>
                <div class="little-block"></div>
              </div>
              <NineCellPlayGround :zoneData="allPass.PassZone" />
              <div class="playground-right">
                <div class="little-block"></div>
                <div class="rate">{{ playgroundRightRate[0] + "%" }}</div>
                <div class="little-block"></div>
                <div class="rate">{{ playgroundRightRate[1] + "%" }}</div>
                <div class="little-block"></div>
                <div class="rate">{{ playgroundRightRate[2] + "%" }}</div>
                <div class="little-block"></div>
              </div>
              <div class="legend">
                <img
                  class="attack-arrow"
                  src="../../../../assets/image/playerGround/rightArrow.png"
                  alt=""
                />
                <span class="legend-text">传球数/传球成功率</span>
              </div>
            </div>
          </div>
          <div class="right-box" v-if="!loading">
            <div class="pass-box">
              <div class="short-text">
                <div>场均传球</div>
                <div>521</div>
              </div>
              <div class="short-text">
                <div>场均传中</div>
                <div>10</div>
              </div>
              <div class="long-text">
                <div>场均传球成功率</div>
                <div>82%</div>
              </div>
              <div class="long-text">
                <div>场均传中成功率</div>
                <div>20%</div>
              </div>
            </div>
            <div class="two-table">
              <PassTable />
              <ReceiveTable />
            </div>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import axios from "axios";
import NineCellPlayGround from "../../../playground/NineCellPlayGround";
import PassTable from "./Comps/PassTable";
import ReceiveTable from "./Comps/ReceiveTable";
export default {
  name: "TeamOrganize",
  data() {
    return {
      allPass: "",
      loading: true,
    };
  },
  components: {
    NineCellPlayGround,
    PassTable,
    ReceiveTable,
  },
  computed: {
    //计算纵向3个方向的传球成功率累加
    playgroundTopRate() {
      if (this.allPass["PassZone"] !== undefined) {
        return [
          Math.round(
            (this.allPass["PassZone"][0]["passRatio"] +
              this.allPass["PassZone"][3]["passRatio"] +
              this.allPass["PassZone"][6]["passRatio"]) *
              100
          ) / 100,
          Math.round(
            (this.allPass["PassZone"][1]["passRatio"] +
              this.allPass["PassZone"][4]["passRatio"] +
              this.allPass["PassZone"][7]["passRatio"]) *
              100
          ) / 100,
          Math.round(
            (this.allPass["PassZone"][2]["passRatio"] +
              this.allPass["PassZone"][5]["passRatio"] +
              this.allPass["PassZone"][8]["passRatio"]) *
              100
          ) / 100,
        ];
      }
    },
    //计算横向3个方向的传球成功率累加
    playgroundRightRate() {
      if (this.allPass["PassZone"] !== undefined) {
        return [
          Math.round(
            (this.allPass["PassZone"][0]["passRatio"] +
              this.allPass["PassZone"][1]["passRatio"] +
              this.allPass["PassZone"][2]["passRatio"]) *
              100
          ) / 100,
          Math.round(
            (this.allPass["PassZone"][3]["passRatio"] +
              this.allPass["PassZone"][4]["passRatio"] +
              this.allPass["PassZone"][5]["passRatio"]) *
              100
          ) / 100,
          Math.round(
            (this.allPass["PassZone"][6]["passRatio"] +
              this.allPass["PassZone"][6]["passRatio"] +
              this.allPass["PassZone"][8]["passRatio"]) *
              100
          ) / 100,
        ];
      }
    },
  },
  async created() {
    //发送请求获取allPass数据
    const { data } = await axios.get(
      "http://8.141.159.127:3000/api/v1/players/actions/pass/25716"
    );
    //赋值
    this.allPass = data;
    //关闭loading
    this.loading = false;
  },
};
</script>

<style scoped lang="scss">
.box-card {
  margin: auto;
  width: 1440px;
  height: 553px;
}
.pass-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background-color: #194568;
  padding: 0;
}
.pass-main {
  height: 496px;
  padding: 0;
  background-color: #f1f6f9;
}
.all-pass {
  display: flex;
  /*width: 100%;*/
  height: 100%;
  justify-content: space-between;
}
.left-box {
  height: 456px;
  margin-left: 90px;
}
.right-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 560px;
  height: 413px;
  margin-top: 18px;
  margin-right: 70px;
  /*background-color: yellow;*/
  .pass-box {
    display: flex;
    justify-content: space-around;
    width: 100%;
    height: 80px;
    /*background-color: red;*/
    border: 1px solid #bbbbbb;
    border-top: 3px #16c79a solid;
    .short-text {
      width: 100px;
      height: 100%;
      font-size: 20px;
      font-weight: bold;
      /*background-color: #01538B;*/
      div:first-child {
        width: 100%;
        height: 40%;
        /*background-color: #B500FE;*/
        line-height: 32px;
      }
      div:last-child {
        width: 100%;
        height: 60%;
        font-size: 36px;
        line-height: 48px;
        /*background-color: lawngreen;*/
      }
    }
    .long-text {
      width: 140px;
      height: 100%;
      font-size: 20px;
      font-weight: bold;
      /*background-color: saddlebrown;*/
      div:first-child {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 40%;
        /*background-color: #B500FE;*/
        line-height: 32px;
        img {
          width: 20px;
          height: 20px;
        }
      }
      div:last-child {
        width: 100%;
        height: 60%;
        font-size: 36px;
        line-height: 48px;
        /*background-color: lawngreen;*/
      }
    }
  }
  .two-table {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 320px;
    /*background-color: #9a6e3a;*/
  }
}
.playground-container {
  position: relative;
  width: 620px;
  height: 456px;
  /*background-color: red;*/
  margin-top: 18px;
  .playground-top {
    display: flex;
    justify-content: space-between;
    width: 591px;
    /*<!--margin-top: -28px;-->*/
    color: #bd1e1e;
    line-height: 18px;
    font-size: 18px;
    height: 17px;
    /*margin-left: 20px;*/
    text-align: left;
    /*background-color: #656F73;*/
    .little-block {
      width: 3px;
      background-color: #bbbbbb;
      /*background-color: red;*/
    }
    .rate-block {
      width: 80px;
      text-align: center;
      /*background-color: #B500FE;*/
    }
  }
  .playground-right {
    /*display: inline-block;*/
    position: absolute;
    top: 30px;
    left: 603px;
    color: #bd1e1e;
    display: flex;
    /*flex-direction: column;*/
    justify-content: space-between;
    /*align-items: center;*/
    /*<!--margin-left: 9px;-->*/
    /*<!--margin-right: -28px;-->*/
    /*<!--margin-bottom: 17px;-->*/
    width: 17px;
    height: 383px;
    writing-mode: vertical-lr;
    font-size: 18px;
    /*background-color: red;*/
    .little-block {
      height: 3px;
      background-color: #bbbbbb;
      font-size: 25px;
    }
    .rate {
      /*background-color: red;*/
      line-height: 16px;
    }
  }
  .legend {
    display: flex;
    justify-content: space-between;
    /*align-items: center;*/
    /*background-color: yellow;*/
    font-size: 14px;
    width: 591px;
    height: 40px;
    /*margin-top: 22px;*/
    .attack-arrow {
      width: 150px;
      /*height: 40px;*/
    }
    .legend-text {
      line-height: 40px;
    }
  }
}
.ant-v {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /*background-color: red;*/
  line-height: 10px;
  width: 100%;
  height: 223px;
  .two-graph {
    display: flex;
    justify-content: space-between;
    .one-graph {
      width: 230px;
      height: 200px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      .one-graph-title {
        height: 20px;
        line-height: 20px;
      }
    }
  }
  .graph-legend {
    height: 25px;
    color: #656f73;
    font-size: 14px;
    line-height: 25px;
  }
}
</style>
